home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / ChipCD 6.02.iso / macos / files / dragburn.sit / DragonBurn / Dragon Burn Installer / WebHelp / BSSCNBAR.JS < prev    next >
Text File  |  2000-06-26  |  10KB  |  309 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. // RoboHELP« Navigator Bar for WebHelp
  3. // Copyright ⌐ 1999-2000 eHelp Corporation.  All rights reserved.
  4.  
  5. // Version= 4.00
  6.  
  7. // Warning:  Do not modify this file.  It is generated by RoboHELP« and changes will be overwritten.
  8.  
  9. // This file is used to support Navigator bar in WebHelp
  10. // The main functions are Sync toc. Show or Hide Navigator Panel. 
  11.  
  12. // call onBsscNavHide() from bsscright frame.
  13. // Hide the bsscleft frame(Nav). and show the current topic.
  14.  
  15. // call onBsscNavShow() from any frame except bsscright.
  16. // Show the bsscleft frame(Nav). and show the current topic in the bsscright frame. and sync toc.
  17.  
  18. // call onBsscNavSync() from bsscright frame.
  19. // there will be two situation.
  20. // 1. Nav is visible.  Just Sync the toc.( show the Contents panel and highlight the related topic).
  21. // 2. Nav is invisible. First Show the Nav panel. and then Sync the toc.
  22.  
  23.  
  24. // onBsscNavSync(strRelHomePage) strRelHomePage is the Relative Path of the First Page, from the current page's view.
  25. // other function will be called by onContent(). do not call them directly.
  26.  
  27. // onBsscNavSync is modified from onContents() in SyncFromTopic.js. add support DHTML sync. 
  28.  
  29. // BsscNavHasNavFrame() determine the Nav frame exists or not
  30.  
  31.  
  32. var gbDHTML = false;
  33.  
  34. var strAgent   = navigator.userAgent.toLowerCase();
  35. var strVersion = navigator.appVersion.toLowerCase();
  36.  
  37. var gnVerMajor = parseInt(strVersion);
  38. var gnVerMinor = parseFloat(strVersion);
  39.  
  40. var gbNS     = ((strAgent.indexOf("mozilla") != -1) && ((strAgent.indexOf('spoofer') == -1) && (strAgent.indexOf('compatible') == -1)));
  41. var gbIE     = (strAgent.indexOf("msie") != -1);
  42. var gbOpera  = (strAgent.indexOf("opera") != -1);
  43. var gbHotJava= (strVersion.indexOf("hotjava") != -1);
  44.  
  45. var gbWin16   = ((strVersion.indexOf("win16") != -1) || (strVersion.indexOf("windows 3.1") != -1));
  46. var gbWindows = ((strAgent.indexOf("win") != -1) || (strAgent.indexOf("16bit") != -1));
  47. var gbMac     = (strAgent.indexOf("mac") != -1);
  48. var gbWebTV   = (strAgent.indexOf("webtv") != -1);
  49. var gbSunOS   = (strAgent.indexOf("sunos") != -1);
  50.  
  51. var gbNS2         = ((gbNS) && (gnVerMajor == 2));
  52. var gbNS3         = ((gbNS) && (gnVerMajor == 3));
  53. var gbNS4         = ((gbNS) && (gnVerMajor >= 4));
  54. var gbIE4         = ((gbIE) && (gnVerMajor >= 4));
  55. var gbIE3         = ((gbIE) && (gnVerMajor <= 3));
  56. var gbIE302before = ((gbIE3) && ((strAgent.indexOf("3.00") != -1)||(strAgent.indexOf("3.0a") != -1)||(strAgent.indexOf("3.0b")!=-1)||(strAgent.indexOf("3.01")!=-1))); 
  57.  
  58. var gbIE5      = ((gbIE4) && (strAgent.indexOf("msie 5") != -1));
  59.  
  60. var nViewFrameType = 2;  //1: DTHTML 2:Applet 3: HTML2 list
  61.  
  62. if (gbIE4 && gbDHTML) nViewFrameType = 1;
  63. if (gbIE4 && gbSunOS) nViewFrameType = 1;
  64.  
  65. if (gbWin16)          nViewFrameType = 3;
  66. if (gbIE3 && gbMac)   nViewFrameType = 3;
  67. if (gbNS2)            nViewFrameType = 3;
  68. if (gbNS3 && gbMac)   nViewFrameType = 3;
  69. if (gbOpera)          nViewFrameType = 3;
  70. if (gbHotJava)        nViewFrameType = 3;
  71. if (gbWebTV)          nViewFrameType = 3;
  72. if (gbIE302before)    nViewFrameType = 3;
  73.  
  74. if ((gbNS4) && (window.screen) && (window.screen.colorDepth == 4))
  75. {
  76.    nViewFrameType = 3;
  77. }
  78.  
  79. function BsscNavIsList() {
  80.     return (nViewFrameType == 3 || (gbIE4 && !gbIE5 && gbMac));
  81. }
  82.  
  83. var gbstrNavnAgent   = navigator.userAgent.toLowerCase();
  84.  
  85. var gbNavnNS    = false;
  86. var gbNavnIE    = false;
  87. gbNavnNS     = ((gbstrNavnAgent.indexOf("mozilla") != -1) && ((gbstrNavnAgent.indexOf('spoofer') == -1) && (gbstrNavnAgent.indexOf('compatible') == -1)));
  88. gbNavnIE        = (gbstrNavnAgent.indexOf("msie") != -1);
  89.  
  90. function BsscNavHasNavFrame()
  91. {
  92.     var bHomePage = false;
  93.     if(gbNavnIE)
  94.     {
  95.         // IE
  96.         if ((parent) && ("object" == typeof(parent.document)) && (parent.document.frames) && (parent.document.frames.length > 1))
  97.             if (parent.document.frames[0].name.indexOf("bsscleft") == 0) {
  98.                 bHomePage=true;
  99.             }
  100.  
  101.     } 
  102.     if(gbNavnNS)
  103.     {
  104.         // Netscape 
  105.         if((parent)&&(parent.window.myname == "webhelp"))
  106.             bHomePage=true;
  107.     }
  108.     return bHomePage;
  109. }
  110.  
  111. // call onBsscNavHide() from bsscright frame.
  112. // Hide the bsscleft frame(Nav). and show the current topic.
  113. function onBsscNavHide()
  114. {
  115.     
  116.     if (BsscNavHasNavFrame()) {
  117.         var strURL = document.URL;
  118.         if (strURL.toLowerCase().indexOf("file://") == 0) {
  119.             strURL = _bsscnBarReplaceSpecialChar(strURL);
  120.         }
  121.         parent.window.location.replace(strURL);
  122.     }
  123. }
  124.  
  125. // call onBsscNavShow() from any frame except bsscright.
  126. // Show the bsscleft frame(Nav). and show the current topic in the bsscright frame. and sync toc.
  127. function onBsscNavShow(strRelHomePageShow)
  128. {
  129.     if (!BsscNavHasNavFrame()) {
  130.         var strRelHomePage = _bsscnBarReplaceSlash(strRelHomePageShow);
  131.     
  132.         var strCurrentURL = document.URL;
  133.         var strCurrentURL = _bsscnBarReplaceSlash(strCurrentURL);
  134.     
  135.         var strCurrentPath = _bsscnBarGetPath(strCurrentURL);
  136.         var strCurrentFile = _bsscnBarGetFileName(strCurrentURL);
  137.     
  138.         var strAbsHomePageURL = _bsscnBarGetAbsoluteHomePageURL(strRelHomePage, strCurrentPath);
  139.     
  140.         var strAbsHomePagePath = _bsscnBarGetPath(strAbsHomePageURL);
  141.         var strAbsHomePagePath = strAbsHomePagePath + "/";
  142.     
  143.         var startpos  = strCurrentURL.indexOf(strAbsHomePagePath);
  144.         if (startpos != -1) {
  145.             strRelativeURL = strCurrentURL.substring(startpos + strAbsHomePagePath.length, strCurrentURL.length);
  146.             if (strAbsHomePageURL.toLowerCase().indexOf("file://") == 0) 
  147.                 strAbsHomePageURL = _bsscnBarReplaceSpecialChar(strAbsHomePageURL);
  148.             location.replace(strAbsHomePageURL+"#" + strRelativeURL);
  149.         }
  150.     }
  151. }
  152.  
  153. function onBsscNavSync(strRelHomePageSync)
  154. {
  155.     var strRelHomePage = _bsscnBarReplaceSlash(strRelHomePageSync);
  156.     
  157.     var strCurrentURL = document.URL;
  158.     var strCurrentURL = _bsscnBarReplaceSlash(strCurrentURL);
  159.     
  160.     var strCurrentPath = _bsscnBarGetPath(strCurrentURL);
  161.     var strCurrentFile = _bsscnBarGetFileName(strCurrentURL);
  162.     
  163.     var strAbsHomePageURL = _bsscnBarGetAbsoluteHomePageURL(strRelHomePage, strCurrentPath);
  164.     
  165.     var strAbsHomePagePath = _bsscnBarGetPath(strAbsHomePageURL);
  166.     var strAbsHomePagePath = strAbsHomePagePath + "/";
  167.     
  168.     var startpos  = strCurrentURL.indexOf(strAbsHomePagePath);
  169.     
  170.     if (startpos != -1) {
  171.         strRelativeURL = strCurrentURL.substring(startpos + strAbsHomePagePath.length, strCurrentURL.length);
  172.         if (BsscNavHasNavFrame()) {
  173.             if(gbNavnIE) {// IE
  174.                 if (parent.document.frames[0].document.applets.length > 0) {
  175.                     if (typeof(parent.document.frames[0].document.applets["webhelp"]) != "undefined") {
  176.                         parent.document.frames[0].document.applets["webhelp"].Command("SyncToc", strRelativeURL);
  177.                     }
  178.                 }
  179.                 else {
  180.                     // probably DHTML
  181.                     if (typeof(parent.document.frames[0].document.frames["Tabs"]) != "undefined") {
  182.                         var tabFrame = parent.document.frames[0].document.frames["Tabs"];
  183.                         _bsscnBarSelectTOC(strRelativeURL);
  184.                     } 
  185.                     else { // it must be list
  186.                     }
  187.                 }
  188.             }
  189.             else { // Probably Netscape.
  190.                 if (parent.frames[0].document.applets.length > 0) {
  191.                     if (typeof(parent.frames[0].document.applets["webhelp"]) != "undefined") {
  192.                         parent.frames[0].document.applets["webhelp"].Command("SyncToc", strRelativeURL);
  193.                     }
  194.                 }
  195.                 else {
  196.                     // probably DHTML
  197.                     if (typeof(parent.document.frames[0].document.frames["Tabs"]) != "undefined") {
  198.                         _bsscnBarSelectTOC(strRelativeURL);
  199.                     }
  200.                     else { // it must be list
  201.                     }
  202.                 }
  203.             }
  204.         }
  205.         else
  206.             //location.replace(strAbsHomePageURL+"#" + strRelativeURL);
  207.             onBsscNavShow(strRelHomePage);
  208.     }
  209. }
  210.  
  211.  
  212. // replace %20 to ' '
  213. function _bsscnBarReplaceSpecialChar(strURL)
  214. {    
  215.     var strReplacedURL = "";
  216.     for (i = 0; i < strURL.length; i ++ )
  217.     {
  218.         if (strURL.charAt(i) == '%') {
  219.             if (strURL.substring(i + 1, i + 3) == "20") {
  220.                 strReplacedURL = strReplacedURL + " ";
  221.                 i += 2;
  222.             }
  223.         }
  224.         else
  225.             strReplacedURL = strReplacedURL + strURL.charAt(i);
  226.     }
  227.     return strReplacedURL;
  228. }
  229.  
  230.  
  231. // replace \\ to /
  232. function _bsscnBarReplaceSlash(strURL)
  233. {    
  234.     var strReplacedURL = "";
  235.     for (i = 0; i < strURL.length; i ++ )
  236.     {
  237.         if (strURL.charAt(i) == '\\') 
  238.             strReplacedURL = strReplacedURL + "/"
  239.         else
  240.             strReplacedURL = strReplacedURL + strURL.charAt(i);
  241.     }
  242.     return strReplacedURL;
  243. }
  244.  
  245. // generate absolute URL for the first page.
  246. function _bsscnBarGetAbsoluteHomePageURL(strRelHomePage, strCurrentPath)
  247. {
  248.     if (strCurrentPath.charAt(strCurrentPath.length - 1) == '/') 
  249.         strCurrentPath = strCurrentPath.substring(0, strCurrentPath.length -1);
  250.     for (;;) {
  251.         upDirPos = strRelHomePage.indexOf("../")
  252.         if (upDirPos == 0) {
  253.             DirPos = strCurrentPath.lastIndexOf("/")
  254.             if (DirPos != -1) {
  255.             strCurrentPath = strCurrentPath.substring(0, DirPos)
  256.             }
  257.             strRelHomePage = strRelHomePage.substring(3, strRelHomePage.length);
  258.         }
  259.         if (upDirPos != 0) break;
  260.     }
  261.     return strCurrentPath + "/" + strRelHomePage;
  262. }
  263.  
  264. function _bsscnBarGetPath(strURL)
  265. {
  266.     pathpos = strURL.lastIndexOf("/");
  267.     if (pathpos > 0)
  268.         return strURL.substring(0, pathpos);
  269.     else 
  270.         return "";
  271. }
  272.  
  273. function _bsscnBarGetFileName(strURL)
  274. {
  275.     pathpos = strURL.lastIndexOf("/");
  276.     if (pathpos > 0)
  277.         return strURL.substring(pathpos + 1, strURL.length);
  278.     else
  279.         return strURL;
  280. }
  281.  
  282. function _bsscnBarGetTabFrame()
  283. {
  284.     if(gbNavnIE) {// IE
  285.         return parent.document.frames[0];
  286.     }
  287.     else { // Netscape
  288.         return parent.frames[0];
  289.     }
  290. }
  291.  
  292. function _bsscnBarSelectTOC(strRelativeURL)
  293. {
  294.     var TabFrame = _bsscnBarGetTabFrame();
  295.     if ("function" == typeof(TabFrame.syncToc))
  296.         TabFrame.syncToc(strRelativeURL);
  297. }
  298.  
  299.  
  300. function _bsscnBarOnError(message)
  301. {
  302.     if(-1 != message.indexOf("denied") 
  303.         || -1 != message.indexOf("Object required"))
  304.      return true;
  305. }
  306.  
  307. onerror = _bsscnBarOnError;
  308.  
  309.